package com.project.lk.nurseapp.nurse.presenter;

import com.project.lk.nurseapp.base.BaseApi;
import com.project.lk.nurseapp.base.BasePresenter;
import com.project.lk.nurseapp.base.ModelPresenterBridge;
import com.project.lk.nurseapp.msg.model.AppMsgItemBean;
import com.project.lk.nurseapp.nurse.model.ChatListItemBean;
import com.project.lk.nurseapp.nurse.model.ChatListModel;
import com.project.lk.nurseapp.nurse.model.EvaluateChatModel;

import java.util.List;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class ChatListPresenter extends BasePresenter<IChatListView>  implements ModelPresenterBridge {

    ChatListModel chatListModel;
    EvaluateChatModel evaluateChatModel;
    public ChatListPresenter(IChatListView view) {
        addView(view);
        chatListModel=new ChatListModel();
        evaluateChatModel=new EvaluateChatModel();
        evaluateChatModel.setBridge(this);
        chatListModel.setBridge(this);
    }

    public List<ChatListItemBean> getList(){
        return chatListModel.getmList();
    }
    //评论
    public void evaluateChat(String url,String sessionId,String star,String content){
        evaluateChatModel.postLoadJson(url,sessionId,star,content);
    }
    public void refresh(String url,String sessionStatus){
        chatListModel.refresh();
        chatListModel.postLoadJson(url,sessionStatus);

    }

    public void loadMore(String url,String sessionStatus){
        chatListModel.loadMore();
        chatListModel.postLoadJson(url,sessionStatus);
    }

    @Override
    public void bridge(int action, List list) {
        if (view != null) {
            switch (action) {
                case BaseApi.show_list:
                    view.showList();
                    break;
                case BaseApi.fail:
                    view.fail();
                    break;
                case BaseApi.noMore:
                    view.noMore();
                    break;
                case BaseApi.evaluate_success:
                    view.evaluateSuccess();
                    break;
                case BaseApi.evaluate_fail:
                    view.evaluateFail();
                    break;
            }
        }
    }
}
